home *** CD-ROM | disk | FTP | other *** search
- Path: news.umbc.edu!not-for-mail
- From: schlein@umbc.edu (Jonas J. Schlein)
- Newsgroups: comp.lang.c
- Subject: Re: How do you clear the keyboard buffer in c?
- Date: 6 Jan 1996 21:28:18 -0500
- Organization: University of Maryland Baltimore County
- Message-ID: <4cnb42$2fn@umbc9.umbc.edu>
- References: <4ao8ed$q9h@news.aloha.com> <NEWTNews.819188338.12128.silver@dialup.netvision.net.il> <4cl3v1$4u1@news-e2a.gnn.com>
- NNTP-Posting-Host: f-umbc9.umbc.edu
- NNTP-Posting-User: schlein
-
- Kevin Kalstein <MrBurns@gnn.com> wrote:
- |> hmm, i think you can also do:
- |>
- |> fflush(stdin);
-
- If you only 'think' and don't actually 'know' then perhaps it is best not
- to give possibly incorrect advice which can mess up the original poster
- even more. I'm honestly not trying to be a smart***, but this is a FAQ!
-
- 12.26: How can I flush pending input so that a user's typeahead isn't
- read at the next prompt? Will fflush(stdin) work?
-
- A: fflush() is defined only for output streams. Since its
- definition of "flush" is to complete the writing of buffered
- characters (not to discard them), discarding unread input would
- not be an analogous meaning for fflush on input streams.
-
- There is no standard way to discard unread characters from a
- stdio input stream, nor would such a way be sufficient unread
- characters can also accumulate in other, OS-level input buffers.
-
- References: ANSI Sec. 4.9.5.2; ISO Sec. 7.9.5.2; H&S Sec. 15.2.
- --
- "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
-
- Jonas J. Schlein (schlein@gl.umbc.edu)
-